package hsqldb;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class HSqlDBInitListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		try {
			UnpooledDataSource ds = DBUtils.createUnpooledDataSource("hsqldb/hsqldb.properties");
			DBUtils.runScript(ds, "hsqldb/hsqldb-schema.sql");
			DBUtils.runScript(ds, "hsqldb/hsqldb-data.sql");
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		
	}

	
}
